home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / hungerstrike.swf / scripts / __Packages / actionscript / Bullet.as next >
Encoding:
Text File  |  2007-09-28  |  1.7 KB  |  63 lines

  1. class actionscript.Bullet extends MovieClip
  2. {
  3.    var _hitTheTarget;
  4.    var _maxDistance;
  5.    var _canSlowDown;
  6.    var game;
  7.    var _type;
  8.    var _speedX;
  9.    var _speedY;
  10.    var _distance;
  11.    var tMc;
  12.    var _damage;
  13.    var _wLevel;
  14.    function Bullet()
  15.    {
  16.       super();
  17.       this._hitTheTarget = false;
  18.       this._maxDistance = false;
  19.       this._canSlowDown = true;
  20.       this.game = this._parent._parent;
  21.       ┬º┬ºpush(this.gotoAndStop(this._type));
  22.       if(this.game._sfxOn)
  23.       {
  24.          var _loc3_ = new Sound();
  25.          _loc3_.attachSound(this._type + "_sound");
  26.          _loc3_.start();
  27.       }
  28.    }
  29.    function calcDistance(p1x, p1y, p2x, p2y)
  30.    {
  31.       var _loc2_ = Math.abs(p1x - p2x);
  32.       var _loc1_ = Math.abs(p1y - p2y);
  33.       var _loc3_ = Math.sqrt(_loc2_ * _loc2_ + _loc1_ * _loc1_);
  34.       return _loc3_;
  35.    }
  36.    function onEnterFrame()
  37.    {
  38.       this._x += this._speedX;
  39.       this._y += this._speedY;
  40.       if(this.calcDistance(0,0,this._x,this._y) > this._distance)
  41.       {
  42.          if(this._type == "Fries" && this.tMc._type == "Ping Pangs" || this._type == "Pepsi" && this.tMc._type == "Skull" || this._type == "Wings" && this.tMc._type == "Pang Pangs" || this._type == "Pepsi" && this.tMc._type == "Orangupangs")
  43.          {
  44.             this._canSlowDown = false;
  45.             this.removeMovieClip();
  46.          }
  47.          else
  48.          {
  49.             this.tMc.loseEnergy(this._damage);
  50.          }
  51.          if(this._type == "Pepsi" && this._canSlowDown)
  52.          {
  53.             this.tMc.slowDownEnemy(this._wLevel);
  54.          }
  55.          this.removeMovieClip();
  56.       }
  57.    }
  58.    function removeBullet()
  59.    {
  60.       this.removeMovieClip();
  61.    }
  62. }
  63.